package com.fhz.roomtest

/**
 * 时间:2023/3/28
 * @author Mr.Feng
 * 简述: TODO
 */
fun main(){
    var p:Person? = null
    p = Person()

    p?.fun1()  //避免空指针
    p?.fun2()
    p?.fun3()

    val let = p?.also {
        it.fun1()
        it.fun2()
        it.fun3()
    }
//    println(let)


    val run = p?.run {
        fun1()
        fun2()
        fun3()
        10
    }
    println(run)

    with(p){
        fun1()
        fun2()
        fun3()
    }



    var s =  StringBuffer()
    s.append("1")
    s.append("2")
    s.append("3")

    with(s){
        append("1")
        append("2")
        append("3")
    }

    val apply = s.apply {
        append("4")
        append("5")
    }
    apply.append("6")



}

class Person() {
    fun fun1(){ println("person fun1") }
    fun fun2(){ println("person fun2") }
    fun fun3(){ println("person fun3") }
}
